From 0fdb0ce2841ba24d2994dc88540c87a8669edbae Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 28 Sep 2015 13:15:17 +0200 Subject: [PATCH] Fix most PHP CodeSniffer warnings in includes/api Change-Id: I01bb3e4c96d6034a5b6c18728bb0574c710ea9db --- includes/api/ApiBase.php | 4 +++- includes/api/ApiCreateAccount.php | 4 +++- includes/api/ApiFeedContributions.php | 3 ++- includes/api/ApiFormatJson.php | 3 ++- includes/api/ApiHelp.php | 7 ++++++- includes/api/ApiMain.php | 10 +++++++--- includes/api/ApiModuleManager.php | 4 +++- includes/api/ApiPageSet.php | 3 ++- includes/api/ApiQueryAllImages.php | 3 ++- includes/api/ApiQueryBase.php | 9 ++++++++- includes/api/ApiQueryImageInfo.php | 3 ++- includes/api/ApiQueryLogEvents.php | 5 ++++- includes/api/ApiQueryRandom.php | 3 ++- includes/api/ApiQueryUserInfo.php | 4 +++- includes/api/ApiUpload.php | 24 +++++++++++++++++++----- 15 files changed, 68 insertions(+), 21 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 64dc9a3e71..5a1099e1de 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1071,7 +1071,9 @@ abstract class ApiBase extends ContextSource { * @param int $botMax Maximum value for sysops/bots * @param bool $enforceLimits Whether to enforce (die) if value is outside limits */ - protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null, $enforceLimits = false ) { + protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null, + $enforceLimits = false + ) { if ( !is_null( $min ) && $value < $min ) { $msg = $this->encodeParamName( $paramName ) . " may not be less than $min (set to $value)"; $this->warnOrDie( $msg, $enforceLimits ); diff --git a/includes/api/ApiCreateAccount.php b/includes/api/ApiCreateAccount.php index 5443faca63..00b7de9b6c 100644 --- a/includes/api/ApiCreateAccount.php +++ b/includes/api/ApiCreateAccount.php @@ -118,7 +118,9 @@ class ApiCreateAccount extends ApiBase { 'createaccount-title', 'createaccount-text' ) ); - } elseif ( $this->getConfig()->get( 'EmailAuthentication' ) && Sanitizer::validateEmail( $user->getEmail() ) ) { + } elseif ( $this->getConfig()->get( 'EmailAuthentication' ) && + Sanitizer::validateEmail( $user->getEmail() ) + ) { // Send out an email authentication message if needed $status->merge( $user->sendConfirmationMail() ); } diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 2df5f9f3f4..9c3945e3ce 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -56,7 +56,8 @@ class ApiFeedContributions extends ApiBase { } $msg = wfMessage( 'Contributions' )->inContentLanguage()->text(); - $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . ' [' . $config->get( 'LanguageCode' ) . ']'; + $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . + ' [' . $config->get( 'LanguageCode' ) . ']'; $feedUrl = SpecialPage::getTitleFor( 'Contributions', $params['user'] )->getFullURL(); $target = $params['user'] == 'newbies' diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php index be1b12c358..a319be3943 100644 --- a/includes/api/ApiFormatJson.php +++ b/includes/api/ApiFormatJson.php @@ -93,7 +93,8 @@ class ApiFormatJson extends ApiFormatBase { break; default: - $this->dieUsage( __METHOD__ . ': Unknown value for \'formatversion\'', 'unknownformatversion' ); + $this->dieUsage( __METHOD__ . + ': Unknown value for \'formatversion\'', 'unknownformatversion' ); } } $data = $this->getResult()->getResultData( null, $transform ); diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index f6d124f065..abec828f1b 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -703,7 +703,12 @@ class ApiHelp extends ApiBase { $submodules[] = $manager->getModule( $name ); } } - $help['submodules'] .= self::getHelpInternal( $context, $submodules, $suboptions, $haveModules ); + $help['submodules'] .= self::getHelpInternal( + $context, + $submodules, + $suboptions, + $haveModules + ); $numSubmodules = count( $submodules ); } diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 95ad3ba67c..8e0ba8bb06 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -618,10 +618,13 @@ class ApiMain extends ApiBase { $response->header( "Access-Control-Allow-Origin: $originHeader" ); $response->header( 'Access-Control-Allow-Credentials: true' ); - $response->header( "Timing-Allow-Origin: $originHeader" ); # http://www.w3.org/TR/resource-timing/#timing-allow-origin + // http://www.w3.org/TR/resource-timing/#timing-allow-origin + $response->header( "Timing-Allow-Origin: $originHeader" ); if ( !$preflight ) { - $response->header( 'Access-Control-Expose-Headers: MediaWiki-API-Error, Retry-After, X-Database-Lag' ); + $response->header( + 'Access-Control-Expose-Headers: MediaWiki-API-Error, Retry-After, X-Database-Lag' + ); } } @@ -977,7 +980,8 @@ class ApiMain extends ApiBase { ) ) { $this->dieUsage( - "The '{$module->encodeParamName( 'token' )}' parameter was found in the query string, but must be in the POST body", + "The '{$module->encodeParamName( 'token' )}' parameter was " . + 'found in the query string, but must be in the POST body', 'mustposttoken' ); } diff --git a/includes/api/ApiModuleManager.php b/includes/api/ApiModuleManager.php index a0300ab55d..ba6c144335 100644 --- a/includes/api/ApiModuleManager.php +++ b/includes/api/ApiModuleManager.php @@ -196,7 +196,9 @@ class ApiModuleManager extends ContextSource { $instance = call_user_func( $factory, $this->mParent, $name ); if ( !$instance instanceof $class ) { - throw new MWException( "The factory function for module $name did not return an instance of $class!" ); + throw new MWException( + "The factory function for module $name did not return an instance of $class!" + ); } } else { // create instance from class name diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 1415b794bd..ceb0905bc8 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -58,7 +58,8 @@ class ApiPageSet extends ApiBase { private $mGoodTitles = array(); private $mMissingPages = array(); // [ns][dbkey] => fake page_id private $mMissingTitles = array(); - private $mInvalidTitles = array(); // [fake_page_id] => array( 'title' => $title, 'invalidreason' => $reason ) + /** @var array [fake_page_id] => array( 'title' => $title, 'invalidreason' => $reason ) */ + private $mInvalidTitles = array(); private $mMissingPageIDs = array(); private $mRedirectTitles = array(); private $mSpecialTitles = array(); diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 381938bd25..877423eb4d 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -350,7 +350,8 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { ApiBase::PARAM_DFLT => 'timestamp|url', ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_HELP_MSG => 'apihelp-query+imageinfo-param-prop', - ApiBase::PARAM_HELP_MSG_PER_VALUE => ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ), + ApiBase::PARAM_HELP_MSG_PER_VALUE => + ApiQueryImageInfo::getPropertyMessages( $this->propertyFilter ), ), 'prefix' => null, 'minsize' => array( diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index c66e21b706..c4592c85f7 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -421,7 +421,14 @@ abstract class ApiQueryBase extends ApiBase { $this->addFields( 'ipb_deleted' ); if ( $showBlockInfo ) { - $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry', 'ipb_timestamp' ) ); + $this->addFields( array( + 'ipb_id', + 'ipb_by', + 'ipb_by_text', + 'ipb_reason', + 'ipb_expiry', + 'ipb_timestamp' + ) ); } // Don't show hidden names diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index c7690243c3..736ac45e96 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -339,7 +339,8 @@ class ApiQueryImageInfo extends ApiQueryBase { // in the actual normalised version, only if we can actually normalise them, // so we use the functions scope to throw away the normalisations. if ( !$h->normaliseParams( $image, $finalParams ) ) { - $this->dieUsage( "Could not normalise image parameters for " . $image->getName(), "urlparamnormal" ); + $this->dieUsage( 'Could not normalise image parameters for ' . + $image->getName(), 'urlparamnormal' ); } } diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index d87ad1e375..38be99acb7 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -365,7 +365,10 @@ class ApiQueryLogEvents extends ApiQueryBase { */ private function getAllowedLogActions() { $config = $this->getConfig(); - return array_keys( array_merge( $config->get( 'LogActions' ), $config->get( 'LogActionsHandlers' ) ) ); + return array_keys( array_merge( + $config->get( 'LogActions' ), + $config->get( 'LogActionsHandlers' ) + ) ); } public function getCacheMode( $params ) { diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index 8e7031c079..e553d12a70 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -152,7 +152,8 @@ class ApiQueryRandom extends ApiQueryGeneratorBase { $end = null; } - list( $left, $continue ) = $this->runQuery( $resultPageSet, $params['limit'], $start, $startId, $end ); + list( $left, $continue ) = + $this->runQuery( $resultPageSet, $params['limit'], $start, $startId, $end ); if ( $end === null && $continue === null ) { // Wrap around. We do this even if $left === 0 for continuation // (saving a DB query in this rare case probably isn't worth the diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 251c42bc5d..f916537369 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -149,7 +149,9 @@ class ApiQueryUserInfo extends ApiQueryBase { $vals['ratelimits'] = $this->getRateLimits(); } - if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) ) ) { + if ( isset( $this->prop['realname'] ) && + !in_array( 'realname', $this->getConfig()->get( 'HiddenPrefs' ) ) + ) { $vals['realname'] = $user->getRealName(); } diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 398337b97c..b621cb0dde 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -45,7 +45,8 @@ class ApiUpload extends ApiBase { $this->mParams = $this->extractRequestParams(); $request = $this->getMain()->getRequest(); // Check if async mode is actually supported (jobs done in cli mode) - $this->mParams['async'] = ( $this->mParams['async'] && $this->getConfig()->get( 'EnableAsyncUploads' ) ); + $this->mParams['async'] = ( $this->mParams['async'] && + $this->getConfig()->get( 'EnableAsyncUploads' ) ); // Add the uploaded file to the params array $this->mParams['file'] = $request->getFileName( 'file' ); $this->mParams['chunk'] = $request->getFileName( 'chunk' ); @@ -605,16 +606,29 @@ class ApiUpload extends ApiBase { switch ( $exceptionType ) { case 'UploadStashFileNotFoundException': - $this->dieUsage( 'Could not find the file in the stash: ' . $e->getMessage(), 'stashedfilenotfound' ); + $this->dieUsage( + 'Could not find the file in the stash: ' . $e->getMessage(), + 'stashedfilenotfound' + ); break; case 'UploadStashBadPathException': - $this->dieUsage( 'File key of improper format or otherwise invalid: ' . $e->getMessage(), 'stashpathinvalid' ); + $this->dieUsage( + 'File key of improper format or otherwise invalid: ' . $e->getMessage(), + 'stashpathinvalid' + ); break; case 'UploadStashFileException': - $this->dieUsage( 'Could not store upload in the stash: ' . $e->getMessage(), 'stashfilestorage' ); + $this->dieUsage( + 'Could not store upload in the stash: ' . $e->getMessage(), + 'stashfilestorage' + ); break; case 'UploadStashZeroLengthFileException': - $this->dieUsage( 'File is of zero length, and could not be stored in the stash: ' . $e->getMessage(), 'stashzerolength' ); + $this->dieUsage( + 'File is of zero length, and could not be stored in the stash: ' . + $e->getMessage(), + 'stashzerolength' + ); break; case 'UploadStashNotLoggedInException': $this->dieUsage( 'Not logged in: ' . $e->getMessage(), 'stashnotloggedin' ); -- 2.20.1